/*
 * (C) Copyright 2006-2010 Nuxeo SAS (http://nuxeo.com/) and contributors.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * Contributors:
 *     bstefanescu
 */
package org.nuxeo.gwt.habyt.templates.client;

/**
 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
 * 
 */
public interface Constants {

    public static final String WIDGET_PREFIX = "g:";

    public static final String BIND_CONTROL = "g:bind";

    public static final String WIDGET_TEMPLATE = "g:template";

    /**
     * Special tag name used to construct the content of panel widgets
     */
    public static final String WIDGET_CELL = "g:cell";

    /**
     * A property set on every widget element which is loaded by a template. It
     * points to the corresponding GWT widget. Useful to find widget that are
     * associated to a given DOM element.
     */
    public final static String THIS = "g:this";

    /**
     * A javascript property which is set for all form controls and points to
     * the owner {@link Form} widget so that you can call exposed form methods
     * like submit(), reset() etc.
     * 
     * @see BuiltinFormControl#createJsForm(org.nuxeo.gwt.habyt.templates.client.form.FormWidget)
     *      for all exposed methods.
     */
    public final static String P_FORM = "g_form";

    /** The following attributes applies only for a g:control element */

    /**
     * Custom validate function for a form control.
     * <p>
     * This function can be defined anywhere in the HTML document (event in
     * templates - in which case it will be defined as long as the template is
     * loaded (and thus present) in the DOM).
     * <p>
     * The value is the function name. The function signature must be:
     * <code>String function(Element control)</code>. The function must return
     * null if validation went OK, otherwise an error message.
     * 
     */
    public final static String VALIDATE_FUNCTION = "validate";

    /**
     * The validation error message if validation fails
     */
    public final static String VALIDATE_ERROR = "error";

    /**
     * Required validation for a control form (can be true or false)
     */
    public final static String VALIDATE_REQUIRED = "required";

    /**
     * A form control label.
     */
    public final static String LABEL = "label";
}
